package net.cyndeline.GameMap

import net.cyndeline.entitySystem.EntityRef
import java.util.UUID

/**
 * A single map on a level.
 */
trait LevelMap {
  
  /**
   * Builds a new map, resets previous data is any.
   */
  def build(id: UUID, grid: Grid, name: String)
  
  /** Return the identifier for this map. Must be unique. */
  def id: UUID
  
  /** Return all objects on a specific map coordinate. */
  def objectsAt(x: Int, y: Int): List[EntityRef]
  
  /** Returns the map width. */
  def width: Int
  
  /** Returns the map height. */
  def height: Int
  
  /** 
   * Add an entity to the map that has a map component and a 
   * position component. Throws an exception if the entity to
   * be added doesn't have the required components, since the
   * position of insertion depends on its position component, and
   * not method input.
   * @throws IllegalArgumentException
   */
  @throws[IllegalArgumentException]
  def addObject(entity: EntityRef): Boolean
  
  /**
   * Removes an entity from the map. Throws an exception if the entity
   * doesn't have the required components, or if the component data
   * (such as position) isn't synchronized with the map.
   * @throws IllegalArgumentException
   */
  @throws[IllegalArgumentException]
  def removeObject(entity: EntityRef): Boolean
  
  /**
   * The name of the map, mostly to make debugging a bit easier.
   */
  def name: String
  
  /**
   * Returns a deep copy of the map.
   */
  def copy: LevelMap
}